import 'package:hktk_app/model/study/hot_share.dart';
import 'package:hktk_app/util/dao_util.dart';

class StudyDao {
  static Future<List<HotSharedModel>> getHotShared() async {
    String url = "/exam/hotShare";
    // 发送请求
    List<dynamic> data = await httpGET(url: url);
    return data.map((e) {
      if (e is Map<String, dynamic>) {
        return HotSharedModel.fromJson(e);
      } else {
        throw ArgumentError('Element is not a <String, dynamic>');
      }
    }).toList();
    // return HotSharedModel.fromJson(data);
  }

  // 热门资讯
  static Future<dynamic> getHotInfos() async {
    String url = "/material/info/hot-infos";
    return await httpGET(url: url);
  }

//
// 根据考试和类型获取资讯资料
  static Future<dynamic> getHotIndex({
    required int type,
     String? examId,
    int num = 5,
    int? categoryId,
  }) async {
    String url="";
    if(categoryId == null){
       url = "/material/info/index-list?type=$type&examId=$examId&num=$num";
    }else{
      url = "/material/info/index-list?type=$type&categoryId=$categoryId&num=$num";
    }

    return await httpGET(url: url);
  }
}
